package controller.memo;

import java.sql.SQLException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import memo.model.service.MemoService;
import memo.model.vo.MemoVO;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;

public class MemoController extends MultiActionController {
	private MemoService memoService;
	public void setMemoService(MemoService memoService) {
		this.memoService = memoService;
	}
	
	public ModelAndView memoShowConetentMain(HttpServletRequest request,
			HttpServletResponse response, MemoVO vo){
		
		String sEmpNo = request.getParameter("empno");
		String sMemoNo = request.getParameter("memono");
		int empNo = Integer.parseInt(sEmpNo);
		int memoNo = Integer.parseInt(sMemoNo);
		vo.setEmpNo(empNo);		vo.setMemoNo(memoNo);
		
		System.out.println(empNo + "   " + memoNo);
		try {
			vo = memoService.showContent(vo);
			System.out.println(vo.toString());
			HttpSession session = request.getSession(false);
			session.setAttribute("memoVO", vo);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		
		return new ModelAndView("memoConetentMain");
	}
}	
